/**
 * Created by ptt on 2016/5/27/0027.
 */
define(["../maintools/Controller.js", "./tpl.js", "./dataHandle.js", "../../gis/gis/loadMap.js"], function (Controller, tpl, handle, map) {
    //initial searchbox has bug for global value jQuery
    tpl = tpl.searchbox;
    Controller = Controller.Controller;
    map = map.map;
    var ghCount;
    var ajaxUrl = null;
	var name = null;
	var count = 1;
	var selector = null;
	//选中的辖区局
	var selectRegion="all";
	//选中的类型分类
    var selectTypeClass="规划项目";
	//选中的子项
	var selectTypeClassChild="全部";
	//默认排序
	var selectSort="default";
    //
    var indexData={
		"project":{
			content:["规划项目","前期项目","施工项目","大中修项目"],
			querUrl:{
				"规划项目":queryConfig.queryProject,
				"前期项目":queryConfig.queryProject,
				"施工项目":queryConfig.queryProject,
				"大中修项目":queryConfig.queryProject
			},
			dataUrl:{
				"规划项目":"/ssjc/pl/planpreparepoj!list.action?fromParam=all&",
				"前期项目":"/ssjc/pre/preparepoj!list.action?",
				"施工项目":"/ssjc/mp/project!list.action?",
				"大中修项目":"/ssjc/yh/maintenance!list.action?fromParam=json&"
			},
			dataType:{
				"规划项目":"WFS",
				"前期项目":"WFS",
				"施工项目":"WFS",
				"大中修项目":"WFS"
			},
			childData:{
				"规划项目":{},
				"前期项目":{},
				"施工项目":{},
				"大中修项目":{}
			},
			sortType:{
				"规划项目":["",""],
				"前期项目":[],
				"施工项目":[],
				"大中修项目":[]
			},
			detailUrl:{
				"规划项目":porjectConfig.planproject.detailUrl,
				"前期项目":porjectConfig.earlierproject.detailUrl,
				"施工项目":porjectConfig.constructproject.detailUrl,
				"大中修项目":porjectConfig.repairproject.detailUrl
			}
		},
		"road":{
			content:["公路","市政道路"],
			querUrl:{
				"公路":queryConfig.queryRoad,
				"市政道路":queryConfig.queryRoad
			},
			dataUrl:{
				"公路":"/ssjc/dl/roadbasicinfo!list.action?filter_EQS_type=101",
				"市政道路":"/ssjc/dl/roadbasicinfo!list.action?filter_EQS_type=102",
				"全部":"/ssjc/dl/roadbasicinfo!list.action"
			},
			dataType:{
				"公路":"WFS",
				"市政道路":"WFS"
			},
			childData:{
				"公路":{
					content:["高速公路","一级公路","二级公路","三级公路","四级公路"],
					queryCondition:
					{
						"高速公路":"121",
						"一级公路":"222",
						"二级公路":"323",
						"三级公路":"424",
						"四级公路":"525"
					}
				},
				"市政道路":{
					content:["城市快速路","主干道","次干道","支路","街坊路"],
					queryCondition:{
						"城市快速路":"111",
						"主干道":"212",
						"次干道":"313",
						"支路":"414",
						"街坊路":"515"
					}
				}
			},
			sortType:{
				"公路":"",
				"市政道路":""
			},
			detailUrl:{
				"公路":"/ssjc/gis/lifecycle.jsp?",
				"市政道路":"/ssjc/gis/lifecycle.jsp?"
			}
		},
		"bridge":{
			content:["桥梁","隧道"],
			queryUrl:{
				"桥梁":"WMS",
				"隧道":"WMS"
			},
			dataUrl:{
				"桥梁":"/ssjc/dl/bridgebasicinfo!list.action",
				"隧道":"/ssjc/dl/tunnelinfo!list.action"
			},
			dataType:{
				"桥梁":"WMS",
				"隧道":"WMS"
			},
			childData:{
				"桥梁":{
					content:["特大桥","大桥","中桥","小桥","涵洞","人行天桥","其它"],
					queryCondition:{
						"特大桥":"1",
						"大桥":"2",
						"中桥":"3",
						"小桥":"4",
						"涵洞":"5",
						"人行天桥":"6",
						"其它":"9",
					}
				},
				"隧道":{
					content:["短隧道","中隧道","长隧道","特长隧道","其它"],
					queryCondition:{
						"短隧道":"1",
						"中隧道":"2",
						"长隧道":"3",
						"特长隧道":"4",
						"其它":"9"
					}
				}
			},
			sortType:{
				"桥梁":{content:[""],"":{"升序":"","降序":""}},
				"隧道":{content:[""],"":{"升序":"","降序":""}}
			},
			detailUrl:{
				"桥梁":"http://218.17.23.29:8088/simpletb/ReportServer?reportlet=/HBCard.cpt&op=view&bridge_id=",
				"隧道":""
			}
		}
	};
	//辖区局
	var allRegion;
    /*搜索下拉框高度auto 开始*/
	function autoHeight(){
			autodivheight();
			function autodivheight(){
			    var winHeight=0;
				var w2 = 0.68;
			    if (window.innerHeight)
			        winHeight = window.innerHeight;
			    else if ((document.body) && (document.body.clientHeight))
			        winHeight = document.body.clientHeight;
			    if (document.documentElement && document.documentElement.clientHeight)
			        winHeight = document.documentElement.clientHeight;
			    var h = $(".search").height();
			    var w = h/winHeight;
			    if(w>w2){
			    	$(".projectContent #informationCentre").css("height",winHeight-270 +"px");
			    	$(".roadContent #informationCentre").css("height",winHeight-270 +"px");
			    	$(".bridgeContent #informationCentre").css("height",winHeight-270 +"px");
			    }else{
			    	$(".projectContent #informationCentre").css("height","auto");
			    	$(".roadContent #informationCentre").css("height","auto");
			    	$(".bridgeContent #informationCentre").css("height","auto");
			    }
			}
			window.onresize=autodivheight;
		};
	autoHeight();
	/*搜索下拉框高度auto 结束*/
	/*加载动画代码  开始*/
	var loading =
		'<div id="loading">'+
			'<div id="loading-center">'+'&nbsp;&nbsp;&nbsp;查找中...'+
				'<div id="loading-center-absolute">'+
					'<div class="object" id="first_object"></div>'+
					'<div class="object" id="second_object" style="float:right;"></div>'+
				'</div>'+
			'</div>'+
		'</div>';
	/*结束*/
    $("#searchContain").html(tpl.render());
    var Trigger = Controller.create({
        elements: {
            "button.js-search": "searchButton",
            "input.js-search": "searchBox",
            "span.close": "closeButton"
        },
        events: {
        	//"oninput input.js-search": "checkDisable",
            "keyup input.js-search": "checkDisable",
            "focus input.js-search": "checkDisable",
            "click button.js-search": "checkDisable",
            "click span.close": "closeSearch",
            "click input.js-search": "onClick",
            "click div.popup_close":"onClose",
            "click ul.container li":"onContainer",
            "click ul.projectBranch li":"onProjectBranch",
            "click ul.projectBranch div.screen ul li":"changeRegion",
            "click div.informationCentre div.info":"mapLinkage",//点击定位事件
            "click button.dl-search": "roadSearch",
        },
        loading: function () {
            this.searchButton.removeClass("css-select").addClass("loading");
        },
        loadend: function () {
            this.searchButton.removeClass("loading").addClass("css-select");
        },
        searchFun: function () {
            this.loading();
            var f = ol.format.ogc.filter;
            var featureRequest = new ol.format.WFS().writeGetFeature({
                srsName: 'EPSG:4326',
                featureNS: 'http://192.168.0.50:9898/szroad',
                featurePrefix: 'szroad',
                featureTypes: ['ptroad'],
                outputFormat: 'application/json',
                filter: f.like('name', '*' + this.searchBox.val() + '*')
            });
            fetch(mapURL.tgisRoadWfsUrl, {
                method: 'POST',
                body: new XMLSerializer().serializeToString(featureRequest)
            }).then(function(response) {
                return response.json();
            }).then(this.proxy(function(json) {
                var features = new ol.format.GeoJSON().readFeatures(json,{featureProjection: 'EPSG:3857'});
                if (features.length === 1 || this.keyCode === "Enter" || this.click) {
                    Message_bone.trigger("showDetail", {
                        title: this.searchBox.val(),
                        content: features[0].getProperties()
                    });
                   m_reMoveLayerAndolay();
                    var source = new ol.source.Vector();
                    var layer = new ol.layer.Vector({
                        source: source,
                        style: HightLightstyleFunction
                    });
                    source.addFeatures(features);
                    //结果定位
                    if(features.length>0){
                        map.getView().fit(features[0].getGeometry(),map.getSize(),{padding: [170, 50, 30, 150]});
                    }
					m_TempLayer = layer;
                    map.addLayer(layer);
                    Message_bone.trigger("suggestHide");
                } else {
                    var result = [];
                    for (var i = 0; i < Math.min(7, features.length); i += 1) {
                        result.push(features[i].getProperties());
                    }
                    result.length && Message_bone.trigger("suggestShow", [result]);
                }
                this.loadend();
            }));
        },
        checkDisable: function (e) {
            e.preventDefault();
            this.keyCode = e.key;
            this.click = e.type === "click" ? "click" : "";
            this.proxy(handle.checkDisable)(e);
			m_reMoveLayerAndolay();
            if (this.searchBox.val()) {
                Message_bone.trigger("closeButtonShow");
                clearTimeout(this.timer);
                this.timer = null;
                this.timer = setTimeout(this.proxy(this.searchFun), 600);
            }else {
                clearTimeout(this.timer);
                this.timer = null;
                this.closeButton.addClass("hide");
                this.closeButton.unbind("mouseenter mouseleave");
                this.searchBox.prop("value", "");
                Message_bone.trigger("detailHide");
                Message_bone.trigger("suggestHide");
            }
           
           
        },
        jrt: function () {
            Message_bone.on("search", this.proxy(function (e, data) {
                this.searchBox.prop("value", data);
                this.checkDisable(e);
            }));
            Message_bone.on("closeButtonShow", this.proxy(function (e) {
                if (this.closeButton.hasClass("hide")) {
                    this.closeButton.removeClass("hide");
                    this.closeButton.hover(this.proxy(function (e) {
                        this.promptin("close_prompt", "关闭");
                    }), this.proxy(function (e) {
                        this.promptout("close_prompt");
                    }));
                }
            }));
            Message_bone.on("closeButtonHide", this.proxy(function (e) {
                this.closeButton.addClass("hide");
                this.closeButton.unbind("mouseenter mouseleave");
                this.searchBox.prop("value", "");
                this.checkDisable(e);
                Message_bone.trigger("detailHide");
            }));
            this.closeButton.addClass("hide");
            this.searchButton.hover(this.proxy(function (e) {
                this.promptin("search_prompt", "搜索");
            }), this.proxy(function (e) {
                this.promptout("search_prompt");
            }));
        },
        closeSearch: function (e) {
            this.closeButton.addClass("hide");
            this.searchBox.prop("value", "");
            this.checkDisable(e);
            Message_bone.trigger("detailHide");
            Message_bone.trigger("suggestHide");
			m_reMoveLayerAndolay();
            this.promptout("close_prompt");
        },
        promptin: function (klass, text) {
            $("#prompt").find("p.text").text(text);
            $("#prompt").addClass(klass);
        },
        promptout: function (klass) {
            $("#prompt").removeClass(klass);
        },
        timer: '',
        /* add_js start */
        onClick:function(){
        	$("#thematicMap .top span").html("专题图");
        	$(".popup_close").show();
        	$(".search_popup").show();
        	$(".region").hide();
        	$(".time").hide();
			$(".time .year").hide();
        	$(".timeSelection").hide();
        	$(".regionSelection").hide();
        	$(".interactive").hide();
        	$("#thematicMap .titleSelect").css("height","0px");
        	$("#thematicMap .top .png").removeClass("on");
        	$(".box .cont").hide();
        	$(".thematicMap .box .title").removeClass("on");
        	$(".thematicMap .box").find(".title").find(".png").removeClass("on");
			m_reMoveLayerAndolay();
        },
        //搜索功能
        roadSearch:function(e){
        	var val = $("input.js-search").val();
        	var html = $(".projectContent .projectBranch li").eq(1).find("span").html();
        	var project = $(".container li").eq(0).hasClass("hover");
        	var road = $(".container li").eq(1).hasClass("hover");
            var bridge = $(".container li").eq(2).hasClass("hover");
            var pro = !road&&!bridge&&project;
            var roa = road&&!bridge&&!project||!road&&!bridge&&!project;
            var bri = !road&&bridge&&!project;
           if(val==""){}else{
            if(pro){
            	selectTypeClass = $(".projectContent .projectBranch li").eq(1).find("span").html();
            	var selectType = 'project';
            	var condition ='filter_LIKES_projectName_OR_projectCode';
            	if(html=='大中修项目'){condition = 'filter_LIKES_projectName_OR_projectNumber';}
            	selector = ".projectContent";
            	$(".projectContent").show();$(".roadContent").hide();$(".bridgeContent").hide();
            	ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "&fileter_EQS_district=440307&"+condition+"="+val+"";
            	$.ajax({
	        		url:ajaxUrl,
	        		dataType:"json",
	        		type:"GET",
	        		beforeSend:function(){
	        			$(selector+" #informationCentre").css("height","auto");
	        			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
	        			$(selector+" .informationCentre .packet").html(loading);
	        		},
	        		complete:function(data){
	        			if(data.readyState==4)
	        				{
	        				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
		        				var jsonData=JSON.parse(data.responseText);
		        				//请求数据
		        				var jsonProject=jsonData.results;
		        				$(".content .informationCentre .packet").html("");
		        				for(var i=0;i<jsonProject.length;i++){
		        					var j=i+1;
									$(selector + " .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
		        				}
		        				ghCount=jsonData.totalCounts;
		        				//判断，如果内容只有一页就隐藏分页栏
		        				if(ghCount<=10){
		        						$(selector+" .informationCentre .paging").hide();
		        					}else{
		        						$(selector+" .informationCentre .paging").show();
		        					}
		        				if(ghCount==0){
		        					$(selector+" .informationCentre .packet").html("没有该信息！");
		        					$(selector+" .informationCentre .packet").css({"text-align":"center","color":"#EB873B","line-height":"100px"});
		        				}else{
		        					$(selector+" .informationCentre .packet").css({"text-align":"left","color":"red","line-height":"auto"});
		        				}
		        				//分页
		        				$(function(){
		        						$(selector+" #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:ghCount,pg_call_fun:function(count){
										ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "&fileter_EQS_district=440307&"+condition+"="+val+"";
																	
		        							$.ajax({
		        		                		url:ajaxUrl,
		        		                		dataType:"json",
		        		                		type:"GET",
		        		                		beforeSend:function(){
		        		                			$(selector+" #informationCentre").css("height","auto");
		        		                			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
		        		                			$(selector+" .informationCentre .packet").html(loading);
		        		                		},
		        		                		complete:function(data){
		        		                			if(data.readyState==4)
		        		                				{
		        		                				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
		        		        	        				var jsonData=JSON.parse(data.responseText);
		        		        	        				//请求数据
		        		        	        				var jsonProject=jsonData.results;
		        		        	        				$(selector+" .informationCentre .packet").html("");
		        		        	        				for(var i=0;i<jsonProject.length;i++){
		        		        	        					var j=i+1;
																$(selector+" .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
		        		        	        				}
		        		        	        				//高度auto
		        		        	        				$(function(){
		        		        	        					var h = $(".search").height();
		        		        	        					var w2 = 0.8;
		        		        	        					var w;
		        		        	        					autodivheight();
		        		        	        					if(w>w2){autoHeight()}
		        		        	        					function autodivheight(){
		        		        	        					    var winHeight=0;
		        		        	        					    if (window.innerHeight)
		        		        	        					        winHeight = window.innerHeight;
		        		        	        					    else if ((document.body) && (document.body.clientHeight))
		        		        	        					        winHeight = document.body.clientHeight;
		        		        	        					    if (document.documentElement && document.documentElement.clientHeight)
		        		        	        					        winHeight = document.documentElement.clientHeight;
		        		        	        					    w = h/winHeight;
		        		        	        					    return w;
		        		        	        					}
		        		        	        				});
		        		                				}
		        		                		},
		        		                	});
		        						}});
		        					});
		        				//高度auto
		        				$(function(){
		        					var h = $(".search").height();
		        					var w2 = 0.8;
		        					var w;
		        					autodivheight();
		        					if(w>w2){autoHeight()}
		        					function autodivheight(){
		        					    var winHeight=0;
		        					    if (window.innerHeight)
		        					        winHeight = window.innerHeight;
		        					    else if ((document.body) && (document.body.clientHeight))
		        					        winHeight = document.body.clientHeight;
		        					    if (document.documentElement && document.documentElement.clientHeight)
		        					        winHeight = document.documentElement.clientHeight;
		        					    w = h/winHeight;
		        					    return w;
		        					}
		        				});
	        				}
	        		},
	        	});
            }else if(roa){
            	$(".roadContent .projectBranch li").eq(1).find("span").html("公路");
            	selectTypeClass = "公路";
	            $(".container li").eq(1).addClass("hover");
	        	$(".container li").eq(1).find("i").addClass("hover");
            	var selectType = 'road';
            	var condition = 'filter_LIKES_roadName_OR_roadCode';
            	selector = ".roadContent";
            	$(".projectContent").hide();$(".roadContent").show();$(".bridgeContent").hide();
            	ajaxUrl = indexData[selectType].dataUrl["全部"]+"?page.pageSize=10&page.pageNo=" + count + "&"+condition+"="+val+"";
            	$.ajax({
	        		url:ajaxUrl,
	        		dataType:"json",
	        		type:"GET",
	        		beforeSend:function(){
	        			$(selector+" #informationCentre").css("height","auto");
	        			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
	        			$(selector+" .informationCentre .packet").html(loading);
	        		},
	        		complete:function(data){
	        			if(data.readyState==4)
	        				{
	        				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
		        				var jsonData=JSON.parse(data.responseText);
		        				//请求数据
		        				var jsonProject=jsonData.results;
		        				$(".content .informationCentre .packet").html("");
		        				for(var i=0;i<jsonProject.length;i++){
		        					var j=i+1;
									$(selector + " .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
		        				}
		        				ghCount=jsonData.totalCounts;
		        				//判断，如果内容只有一页就隐藏分页栏
		        				if(ghCount<=10){
		        						$(selector+" .informationCentre .paging").hide();
		        					}else{
		        						$(selector+" .informationCentre .paging").show();
		        					}
		        				if(ghCount==0){
		        					$(selector+" .informationCentre .packet").html("没有该信息！");
		        					$(selector+" .informationCentre .packet").css({"text-align":"center","color":"#EB873B","line-height":"100px"});
		        				}else{
		        					$(selector+" .informationCentre .packet").css({"text-align":"left","color":"red","line-height":"auto"});
		        				}
		        				//分页
		        				$(function(){
		        						$(selector+" #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:ghCount,pg_call_fun:function(count){
										ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"?page.pageSize=10&page.pageNo=" + count + "&"+condition+"="+val+"";
										
		        							$.ajax({
		        		                		url:ajaxUrl,
		        		                		dataType:"json",
		        		                		type:"GET",
		        		                		beforeSend:function(){
		        		                			$(selector+" #informationCentre").css("height","auto");
		        		                			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
		        		                			$(selector+" .informationCentre .packet").html(loading);
		        		                		},
		        		                		complete:function(data){
		        		                			if(data.readyState==4)
		        		                				{
		        		                				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
		        		        	        				var jsonData=JSON.parse(data.responseText);
		        		        	        				//请求数据
		        		        	        				var jsonProject=jsonData.results;
		        		        	        				$(selector+" .informationCentre .packet").html("");
		        		        	        				for(var i=0;i<jsonProject.length;i++){
		        		        	        					var j=i+1;
																$(selector+" .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
		        		        	        				}
		        		        	        				//高度auto
		        		        	        				$(function(){
		        		        	        					var h = $(".search").height();
		        		        	        					var w2 = 0.8;
		        		        	        					var w;
		        		        	        					autodivheight();
		        		        	        					if(w>w2){autoHeight()}
		        		        	        					function autodivheight(){
		        		        	        					    var winHeight=0;
		        		        	        					    if (window.innerHeight)
		        		        	        					        winHeight = window.innerHeight;
		        		        	        					    else if ((document.body) && (document.body.clientHeight))
		        		        	        					        winHeight = document.body.clientHeight;
		        		        	        					    if (document.documentElement && document.documentElement.clientHeight)
		        		        	        					        winHeight = document.documentElement.clientHeight;
		        		        	        					    w = h/winHeight;
		        		        	        					    return w;
		        		        	        					}
		        		        	        				});
		        		                				}
		        		                		},
		        		                	});
		        						}});
		        					});
		        				//高度auto
		        				$(function(){
		        					var h = $(".search").height();
		        					var w2 = 0.8;
		        					var w;
		        					autodivheight();
		        					if(w>w2){autoHeight()}
		        					function autodivheight(){
		        					    var winHeight=0;
		        					    if (window.innerHeight)
		        					        winHeight = window.innerHeight;
		        					    else if ((document.body) && (document.body.clientHeight))
		        					        winHeight = document.body.clientHeight;
		        					    if (document.documentElement && document.documentElement.clientHeight)
		        					        winHeight = document.documentElement.clientHeight;
		        					    w = h/winHeight;
		        					    return w;
		        					}
		        				});
	        				}
	        		},
	        	});
            }else if(bri){
            	var dao = $(".bridgeContent .projectBranch li").eq(1).find("span").attr("data-dao");
            	var str = null;
            	if(dao=="one"){
            		selectTypeClass = "桥梁";
            		str = '&filter_LIKES_bridgeName_OR_bridgeCode=';
            	}else if(dao=="two"){
            		selectTypeClass = "隧道";
            		str = '&filter_LIKES_bridgeName_OR_tunnelcode=';
            	}
            	var selectType = 'bridge';
            	selector = ".bridgeContent";
            	$(".projectContent").hide();$(".roadContent").hide();$(".bridgeContent").show();
            	ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"?page.pageSize=10&page.pageNo=" + count + str +val+"";
            	$.ajax({
            		url:ajaxUrl,
            		dataType:"json",
            		type:"GET",
            		beforeSend:function(){
            			$(selector+" #informationCentre").css("height","auto");
            			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
            			$(selector+" .informationCentre .packet").html(loading);
            		},
            		complete:function(data){
            			if(data.readyState==4)
            				{
            				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
    	        				var jsonData=JSON.parse(data.responseText);
    	        				//请求数据
    	        				var jsonProject=jsonData.results;
    	        				$(".content .informationCentre .packet").html("");
    	        				for(var i=0;i<jsonProject.length;i++){
    	        					var j=i+1;
    								$(selector + " .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
    	        				}
    	        				ghCount=jsonData.totalCounts;
    	        				//判断，如果内容只有一页就隐藏分页栏
    	        				if(ghCount<=10){
    	        						$(selector+" .informationCentre .paging").hide();
    	        					}else{
    	        						$(selector+" .informationCentre .paging").show();
    	        					}
    	        				if(ghCount==0){
    	        					$(selector+" .informationCentre .packet").html("没有该信息！");
    	        					$(selector+" .informationCentre .packet").css({"text-align":"center","color":"#EB873B","line-height":"100px"});
    	        				}else{
    	        					$(selector+" .informationCentre .packet").css({"text-align":"left","color":"red","line-height":"auto"});
    	        				}
    	        				//分页
    	        				$(function(){
    	        						$(selector+" #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:ghCount,pg_call_fun:function(count){
    									ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"?page.pageSize=10&page.pageNo=" + count +str+val+"";
    									
    	        							$.ajax({
    	        		                		url:ajaxUrl,
    	        		                		dataType:"json",
    	        		                		type:"GET",
    	        		                		beforeSend:function(){
    	        		                			$(selector+" #informationCentre").css("height","auto");
    	        		                			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
    	        		                			$(selector+" .informationCentre .packet").html(loading);
    	        		                		},
    	        		                		complete:function(data){
    	        		                			if(data.readyState==4)
    	        		                				{
    	        		                				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
    	        		        	        				var jsonData=JSON.parse(data.responseText);
    	        		        	        				//请求数据
    	        		        	        				var jsonProject=jsonData.results;
    	        		        	        				$(selector+" .informationCentre .packet").html("");
    	        		        	        				for(var i=0;i<jsonProject.length;i++){
    	        		        	        					var j=i+1;
    															$(selector+" .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
    	        		        	        				}
    	        		        	        				//高度auto
    	        		        	        				$(function(){
    	        		        	        					var h = $(".search").height();
    	        		        	        					var w2 = 0.8;
    	        		        	        					var w;
    	        		        	        					autodivheight();
    	        		        	        					if(w>w2){autoHeight()}
    	        		        	        					function autodivheight(){
    	        		        	        					    var winHeight=0;
    	        		        	        					    if (window.innerHeight)
    	        		        	        					        winHeight = window.innerHeight;
    	        		        	        					    else if ((document.body) && (document.body.clientHeight))
    	        		        	        					        winHeight = document.body.clientHeight;
    	        		        	        					    if (document.documentElement && document.documentElement.clientHeight)
    	        		        	        					        winHeight = document.documentElement.clientHeight;
    	        		        	        					    w = h/winHeight;
    	        		        	        					    return w;
    	        		        	        					}
    	        		        	        				});
    	        		                				}
    	        		                		},
    	        		                	});
    	        						}});
    	        					});
    	        				//高度auto
    	        				$(function(){
    	        					var h = $(".search").height();
    	        					var w2 = 0.8;
    	        					var w;
    	        					autodivheight();
    	        					if(w>w2){autoHeight()}
    	        					function autodivheight(){
    	        					    var winHeight=0;
    	        					    if (window.innerHeight)
    	        					        winHeight = window.innerHeight;
    	        					    else if ((document.body) && (document.body.clientHeight))
    	        					        winHeight = document.body.clientHeight;
    	        					    if (document.documentElement && document.documentElement.clientHeight)
    	        					        winHeight = document.documentElement.clientHeight;
    	        					    w = h/winHeight;
    	        					    return w;
    	        					}
    	        				});
            				}
            		},
            	});
            }
        }},
        //初始化
        onClose:function(){
        	$(".popup_close").hide();
        	$(".search_popup").hide();
        	$(".container li").removeClass("hover");
        	$(".container li i").removeClass("hover");
        	$(".projectBranch li").removeClass("hover");
        	$(".projectBranch li i").removeClass("hover");
        	$(".content").hide();
        	$(".projectBranch .screen").hide();
        	$(".informationCentre .packet").html("");
        	$(".informationCentre .paging").hide();
        	$("#informationCentre").css("height","auto");
        	$("#searchContain .js-search").val("");
        	$("#searchContain .close").hide();
			//清除地图
			m_reMoveLayerAndolay();
        },
        //顶级栏目筛选
        onContainer:function(e){
        	var selectType =  e.currentTarget.dataset.type;
			var i=e.currentTarget.dataset.index;

         	$(".container li").eq(i).addClass("hover").siblings().removeClass("hover");
        	$(".container li i").eq(i).addClass('hover').parent().siblings().find("i").removeClass("hover");

			switch (selectType) {
				case"project":
				{
					$(".projectContent").show();
					$(".roadContent").hide();
					$(".bridgeContent").hide();
					$(".projectContent .projectBranch li").removeClass('hover');
					$(".projectContent .projectBranch li i").removeClass('hover');
					$(".roadContent .projectBranch li").removeClass('hover');
					$(".roadContent .projectBranch li i").removeClass('hover');
					$(".bridgeContent .projectBranch li").removeClass('hover');
					$(".bridgeContent .projectBranch li i").removeClass('hover');
					$(".projectBranch .screen").hide();
					$(".informationCentre .paging").show();
					$(".projectContent .projectBranch li").eq(0).find(" span").html("全部辖区");
					$(".projectContent .projectBranch li").eq(1).find(" span").html("规划项目");
					$(".projectContent .projectBranch li").eq(2).find(" span").html("默认排序");
					selector = ".projectContent";
					ajaxUrl = indexData[selectType].dataUrl["规划项目"]+"page.pageSize=10&page.pageNo=" + count + "&fileter_EQS_district=440307";
					//初始化默认信息
					 selectRegion="all";
					 selectTypeClass="规划项目";
					 selectTypeClassChild="全部";
					 selectSort="default";
				}
					break;
				case "road":
			         {
						$(".roadContent").show();
						$(".projectContent").hide();
						$(".bridgeContent").hide();
						$(".projectContent .projectBranch li").removeClass('hover');
						$(".projectContent .projectBranch li i").removeClass('hover');
						$(".roadContent .projectBranch li").removeClass('hover');
						$(".roadContent .projectBranch li i").removeClass('hover');
						$(".bridgeContent .projectBranch li").removeClass('hover');
						$(".bridgeContent .projectBranch li i").removeClass('hover');
						$(".projectBranch .screen").hide();
						$(".informationCentre .paging").show();
						$(".roadContent .projectBranch li").eq(0).find(" span").html("全部辖区");
						$(".roadContent .projectBranch li").eq(1).find(" span").html("公路");
						$(".roadContent .projectBranch li").eq(2).find(" span").html("默认排序");
						selector = ".roadContent";
						ajaxUrl = indexData[selectType].dataUrl["公路"]+"&page.pageSize=10&page.pageNo=" + count + "";
						 //初始化默认信息
						 selectRegion="all";
						 selectTypeClass="公路";
						 selectTypeClassChild="全部";
						 selectSort="default";
					}
				break;
				case "bridge":
				{
						$(".bridgeContent").show();
						$(".projectContent").hide();
						$(".roadContent").hide();
						$(".projectContent .projectBranch li").removeClass('hover');
						$(".projectContent .projectBranch li i").removeClass('hover');
						$(".roadContent .projectBranch li").removeClass('hover');
						$(".roadContent .projectBranch li i").removeClass('hover');
						$(".bridgeContent .projectBranch li").removeClass('hover');
						$(".bridgeContent .projectBranch li i").removeClass('hover');
						$(".projectBranch .screen").hide();
						$(".informationCentre .paging").show();
						$(".bridgeContent .projectBranch li").eq(0).find(" span").html("全部辖区");
						$(".bridgeContent .projectBranch li").eq(1).find(" span").html("桥梁");
						$(".bridgeContent .projectBranch li").eq(2).find(" span").html("默认排序");
						selector = ".bridgeContent";
						ajaxUrl = indexData[selectType].dataUrl["桥梁"]+"?page.pageSize=10&page.pageNo=" + count + "";
					//初始化默认信息
					selectRegion="all";
					selectTypeClass="桥梁";
					selectTypeClassChild="全部";
					selectSort="default";
					}
					break;
			}
        	//默认加载项目
        	$.ajax({
        		url:ajaxUrl,
        		dataType:"json",
        		type:"GET",
        		beforeSend:function(){
        			$(selector+" #informationCentre").css("height","auto");
        			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
        			$(selector+" .informationCentre .packet").html(loading);
        		},
        		complete:function(data){
        			if(data.readyState==4)
        				{
        				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
	        				var jsonData=JSON.parse(data.responseText);
	        				//请求数据
	        				var jsonProject=jsonData.results;
	        				$(".content .informationCentre .packet").html("");
	        				for(var i=0;i<jsonProject.length;i++){
	        					var j=i+1;
								$(selector + " .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
	        				}
	        				ghCount=jsonData.totalCounts;
	        				//判断，如果内容只有一页就隐藏分页栏
	        				if(ghCount<=10){
	        						$(selector+" .informationCentre .paging").hide();
	        					}else{
	        						$(selector+" .informationCentre .paging").show();
	        					}
	        				if(ghCount==0){
	        					$(selector+" .informationCentre .packet").html("没有该信息！");
	        					$(selector+" .informationCentre .packet").css({"text-align":"center","color":"#EB873B","line-height":"100px"});
	        				}else{
	        					$(selector+" .informationCentre .packet").css({"text-align":"left","color":"red","line-height":"auto"});
	        				}
	        				//分页
	        				$(function(){
	        						$(selector+" #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:ghCount,pg_call_fun:function(count){
										switch (selectType){
											case"project":
												ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "&fileter_EQS_district=440307";
												break;
											case "road":
												ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"&page.pageSize=10&page.pageNo=" + count + "";
												break;
											case "bridge":
												ajaxUrl = indexData[selectType].dataUrl[selectTypeClass]+"?page.pageSize=10&page.pageNo=" + count + "";
												break;
										}
	        							$.ajax({
	        		                		url:ajaxUrl,
	        		                		dataType:"json",
	        		                		type:"GET",
	        		                		beforeSend:function(){
	        		                			$(selector+" #informationCentre").css("height","auto");
	        		                			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
	        		                			$(selector+" .informationCentre .packet").html(loading);
	        		                		},
	        		                		complete:function(data){
	        		                			if(data.readyState==4)
	        		                				{
	        		                				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
	        		        	        				var jsonData=JSON.parse(data.responseText);
	        		        	        				//请求数据
	        		        	        				var jsonProject=jsonData.results;
	        		        	        				$(selector+" .informationCentre .packet").html("");
	        		        	        				for(var i=0;i<jsonProject.length;i++){
	        		        	        					var j=i+1;
															$(selector+" .informationCentre .packet").append(getHtmlByType(selectType,selectTypeClass,jsonProject[i],j,i));
	        		        	        				}
	        		        	        				//高度auto
	        		        	        				$(function(){
	        		        	        					var h = $(".search").height();
	        		        	        					var w2 = 0.8;
	        		        	        					var w;
	        		        	        					autodivheight();
	        		        	        					if(w>w2){autoHeight()}
	        		        	        					function autodivheight(){
	        		        	        					    var winHeight=0;
	        		        	        					    if (window.innerHeight)
	        		        	        					        winHeight = window.innerHeight;
	        		        	        					    else if ((document.body) && (document.body.clientHeight))
	        		        	        					        winHeight = document.body.clientHeight;
	        		        	        					    if (document.documentElement && document.documentElement.clientHeight)
	        		        	        					        winHeight = document.documentElement.clientHeight;
	        		        	        					    w = h/winHeight;
	        		        	        					    return w;
	        		        	        					}
	        		        	        				});
	        		                				}
	        		                		},
	        		                	});
	        						}});
	        					});
	        				//高度auto
	        				$(function(){
	        					var h = $(".search").height();
	        					var w2 = 0.8;
	        					var w;
	        					autodivheight();
	        					if(w>w2){autoHeight()}
	        					function autodivheight(){
	        					    var winHeight=0;
	        					    if (window.innerHeight)
	        					        winHeight = window.innerHeight;
	        					    else if ((document.body) && (document.body.clientHeight))
	        					        winHeight = document.body.clientHeight;
	        					    if (document.documentElement && document.documentElement.clientHeight)
	        					        winHeight = document.documentElement.clientHeight;
	        					    w = h/winHeight;
	        					    return w;
	        					}
	        				});
        				}
        		},
        	});
        },
        //二级栏目筛选
        onProjectBranch:function(e){

        	var selectDataType =  e.currentTarget.dataset.type;
			var i= e.currentTarget.dataset.index;

        	var hasHover = $(".projectBranch li").eq(i).hasClass("hover");
        	var hasHover2 = $(".roadContent .projectBranch li").eq(i).hasClass("hover");
        	var hasHover3 = $(".bridgeContent .projectBranch li").eq(i).hasClass("hover");
        	if(i=="close"){
        		$(".projectBranch li").removeClass('hover');
        		$(".projectBranch li i").removeClass('hover');
        		$(".projectBranch .screen").hide();
        	}
			//获取辖区局信息
			if(!allRegion){
				allRegion=Pengtu.buildCodes("2050");
			}
			var projectContentType=indexData[selectDataType];
			var type=projectContentType.content;
			//初始化
            switch (selectDataType) {
				case "project":
					selector = ".projectContent";
					hasHover = hasHover;
					if (i == 0) {
						if (allRegion) {
							$(selector + " .projectBranch .screen ul").html("");
							$(selector + " .projectBranch .screen ul").html("<li data-chose='all' data-index='region' data-type="+selectDataType+">" + "全部辖区" + "</li>");
							for (var i = 0; i < allRegion.length; i++) {
								j = i + 1;
								$(selector + " .projectBranch .screen ul").append("<li data-chose=" + allRegion[i].value + " data-index='region' data-type="+selectDataType+">" + allRegion[i].label + "区</li>");
							}
						}
					} else if (i == 1) {
						if (type) {
							$(selector + " .projectBranch .screen ul").html("");
							for (var i = 0; i < type.length; i++) {
								$(selector + " .projectBranch .screen ul").append("<li data-chose=" + type[i]  + " data-index='typeClass' data-type="+selectDataType+">" + type[i] + "</li>");
							}
						}
					} else if (i == 2) {
						var sort = [{"sortName": "默认排序"},
							{"sortName": ""}];
						if (sort) {
							$(selector + " .projectBranch .screen ul").html("");
							for (var i = 0; i < sort.length; i++) {
								$(selector + " .projectBranch .screen ul").append("<li data-chose=" + i + " data-index= 'sortType' data-type="+selectDataType+">" + sort[i].sortName + "</li>");
							}
						}
					}
					break;
				case "road":
						selector = ".roadContent";
						hasHover = hasHover2;
						if (i == 0) {
							if (allRegion) {
								$(selector + " .projectBranch .screen ul").html("");
								$(selector + " .projectBranch .screen ul").html("<li data-chose='all' data-index='region' data-type="+selectDataType+">" + "全部辖区" + "</li>");
								for (var i = 0; i < allRegion.length; i++) {
									$(selector + " .projectBranch .screen ul").append("<li data-chose=" + allRegion[i].value + " data-index='region' data-type="+selectDataType+">" + allRegion[i].label + "</li>");
								}
							}
						} else if (i == 1) {
							if (type) {
								$(selector + " .projectBranch .screen ul").html("");
								$(selector + " .projectBranch .screen ul").append(
									'<div class="li"><div class="name">' + type[0] + '</div><ul class="value on"></ul><div style="clear:both;"></div></div>'
									+ '<div class="li"><div class="name">' + type[1] + '</div><ul class="value on_"></ul><div style="clear:both;"></div></div>'
								);
								var childType=projectContentType.childData;
								var typeTwo=childType["公路"];
								var typeThree=childType["市政道路"];
								//初始化二级
								$(selector + " .projectBranch .screen ul .li .on").append("<li data-dao='one' data-chose='公路' data-index='typeClass' data-type="+selectDataType+">全部</li>");
								for (var i = 0; i < typeTwo.content.length; i++) {
									var j = i + 1;
									$(selector + " .projectBranch .screen ul .li .on").append("<li data-dao='one' data-chose='公路' data-index='typeClass' data-type="+selectDataType+">" + typeTwo.content[i]  + "</li>");
								}
								$(selector + " .projectBranch .screen ul .li .on").append('<div style="clear:both;"></div>');
								$(selector + " .projectBranch .screen ul .li .on_").append("<li data-dao='two' data-chose='市政道路'  data-index='typeClass' data-type="+selectDataType+">全部</li>");
								for (var i = 0; i < typeThree.content.length; i++) {
									var j = i + 1;
									$(selector + " .projectBranch .screen ul .li .on_").append("<li data-dao='two' data-chose='市政道路'  data-index='typeClass' data-type="+selectDataType+">" +  typeThree.content[i] + "</li>");
								}
								$(selector + " .projectBranch .screen ul .li .on_").append('<div style="clear:both;"></div>');
							}
						} else if (i == 2) {
							var sort = [{"sortName": "默认排序"},
								{"sortName": ""}];
							if (sort) {
								$(selector + " .projectBranch .screen ul").html("");
								for (var i = 0; i < sort.length; i++) {
									$(selector + " .projectBranch .screen ul").append("<li data-chose=" + i + " data-index='sortType' data-type="+selectDataType+">" + sort[i].sortName + "</li>");
								}
							}
						}
					break;
				case "bridge":
						selector = ".bridgeContent";
						hasHover = hasHover3;
						if (i == 0) {
							if (allRegion) {
								$(selector + " .projectBranch .screen ul").html("");
								$(selector + " .projectBranch .screen ul").html("<li data-chose='all' data-index='region' data-type="+selectDataType+">" + "全部辖区" + "</li>");
								for (var i = 0; i < allRegion.length; i++) {
									$(selector + " .projectBranch .screen ul").append("<li data-chose=" + allRegion[i].value + " data-index='region' data-type="+selectDataType+">" + allRegion[i].label + "</li>");
								}
							}
						} else if (i == 1) {
							if (type) {
								$(selector + " .projectBranch .screen ul").html("");
								$(selector + " .projectBranch .screen ul").append(
									'<div class="li"><div class="name">' + type[0] + '</div><ul class="value on"></ul><div style="clear:both;"></div></div>'
									+ '<div class="li"><div class="name">' + type[1] + '</div><ul class="value on_"></ul><div style="clear:both;"></div></div>'
								);
							}
							var childType=projectContentType.childData;
							var typeTwo=childType["桥梁"];
							var typeThree=childType["隧道"];
							$(selector + " .projectBranch .screen ul .li .on").append("<li data-dao='one' data-chose='桥梁' data-index='typeClass' data-type="+selectDataType+">全部</li>");
							for (var i = 0; i < typeTwo.content.length; i++) {
								var j = i + 1;
								$(selector + " .projectBranch .screen ul .li .on").append("<li data-dao='one' data-chose='桥梁' data-index='typeClass' data-type="+selectDataType+">" + typeTwo.content[i]  + "</li>");
							}
							$(selector + " .projectBranch .screen ul .li .on").append('<div style="clear:both;"></div>');
							$(selector + " .projectBranch .screen ul .li .on_").append("<li data-dao='two' data-chose='隧道' data-index='typeClass' data-type="+selectDataType+">全部</li>");
							for (var i = 0; i < typeThree.content.length; i++) {
								var j = i + 1;
								$(selector + " .projectBranch .screen ul .li .on_").append("<li data-dao='two' data-chose='隧道' data-index='typeClass' data-type="+selectDataType+">" + typeThree.content[i] + "</li>");
							}
							$(selector + " .projectBranch .screen ul .li .on_").append('<div style="clear:both;"></div>');
						} else if (i == 2) {
							var sort = [{"sortName": "默认排序"},
								{"sortName": ""}];
							if (sort) {
								$(selector + " .projectBranch .screen ul").html("");
								for (var i = 0; i < sort.length; i++) {
									$(selector + " .projectBranch .screen ul").append("<li data-chose=" + i + " data-index='sortType' data-type="+selectDataType+">" + sort[i].sortName + "</li>");
								}
							}
						}
					break;
			}
        	var i = e.target.getAttribute("data-index");
        	$(selector+" .projectBranch li").eq(i).addClass('hover').siblings().removeClass("hover");
        	$(selector+" .projectBranch li i").eq(i).addClass('hover').parent().siblings().find("i").removeClass("hover");
        	if(hasHover){
        		$(selector+" .projectBranch li").eq(i).removeClass('hover');
        		$(selector+" .projectBranch li i").eq(i).removeClass('hover');
        		$(selector+" .projectBranch .screen").hide();
        	}else{
        		$(selector+" .projectBranch li").eq(i).addClass('hover');
        		$(selector+" .projectBranch li i").eq(i).addClass('hover');
        		$(selector+" .projectBranch .screen").show();
        	}
        },
        //子类点击筛选一
        changeRegion:function(e){
            //选择类型
            var dataSelectType= e.currentTarget.dataset.type;
        	var typeClassName = e.target.getAttribute("data-index");
			switch (typeClassName){
				case "region":
					selectRegion=e.target.getAttribute("data-chose");
					$(selector + " .projectBranch li span").eq(0).html(e.target.innerText);
					break;
				case "typeClass":
					selectTypeClass=e.target.getAttribute("data-chose");
					selectTypeClassChild=e.target.innerText;
					$(selector + " .projectBranch li span").eq(1).html(e.target.innerText);
					break;
				case "sortType":
					selectSort=e.target.getAttribute("data-chose");
					$(selector + " .projectBranch li span").eq(2).html(e.target.innerText);
					break;
			}
    		$("#informationCentre").css("height","auto");
        	$(".projectBranch .screen").hide();
        	$(".projectBranch li").removeClass("hover");
        	$(".projectBranch li i").removeClass("hover");
			var selectIndexData=indexData[dataSelectType];
			switch (dataSelectType) {
				case"project":{
					switch (selectTypeClass){
						case "规划项目":
							ajaxUrl=selectIndexData.dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "";
							break;
						case "大中修项目":
							ajaxUrl=selectIndexData.dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "";
							break;
						default:
							ajaxUrl=selectIndexData.dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "";
							break;
					}
					switch (selectTypeClass){
						case "规划项目":
							ajaxUrl+=selectRegion=="all"?"":"&filter_EQS_district=" + selectRegion ;
							break;
						case"前期项目":
						case "大中修项目":
							ajaxUrl+=selectRegion=="all"?"":"&filter_EQS_district=" + selectRegion ;
							break;
						case "施工项目":
							ajaxUrl+=selectRegion=="all"?"":"&filter_EQS_district=" + selectRegion ;
							break;
					};
				}
					break;
				case "road":
				{
					switch (selectTypeClass) {
						case "公路":
							ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "&page.pageSize=10&page.pageNo=" + count + "";
							if(selectTypeClassChild== "全部"){$(".roadContent .projectBranch li").eq(1).find("span").html("公路");}
							$(".roadContent .projectBranch li").eq(1).find("span").attr("data-dao","one");
							break;
						case "市政道路":
							ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "&page.pageSize=10&page.pageNo=" + count + "";
							if(selectTypeClassChild== "全部"){$(".roadContent .projectBranch li").eq(1).find("span").html("市政道路");}
							$(".roadContent .projectBranch li").eq(1).find("span").attr("data-dao","two");
							break;
					}
					//添加子条件
					ajaxUrl += selectTypeClassChild== "全部" ? "" : "&filter_EQS_techGrade=" + selectIndexData.childData[selectTypeClass].queryCondition[selectTypeClassChild];
					//添加辖区局条件
					ajaxUrl += selectRegion == "all" ? "" : "&filter_EQS_district=" + selectRegion;
				}
					break;
				case "bridge":
				{
					switch (selectTypeClass) {
						case "桥梁":
							ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "?page.pageSize=10&page.pageNo=" + count + "";
							ajaxUrl += selectTypeClassChild == "全部" ? "" : "&filter_EQS_bridgeKind=" + selectIndexData.childData[selectTypeClass].queryCondition[selectTypeClassChild];
							if(selectTypeClassChild== "全部"){$(".bridgeContent .projectBranch li").eq(1).find("span").html("桥梁");}
							$(".bridgeContent .projectBranch li").eq(1).find("span").attr("data-dao","one");
							break;
						case "隧道":
							ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "?page.pageSize=10&page.pageNo=" + count + "";
							ajaxUrl += selectTypeClassChild == "全部" ? "" : "&filter_EQS_tunnelkind=" + selectIndexData.childData[selectTypeClass].queryCondition[selectTypeClassChild];
							if(selectTypeClassChild== "全部"){$(".bridgeContent .projectBranch li").eq(1).find("span").html("隧道");}
							$(".bridgeContent .projectBranch li").eq(1).find("span").attr("data-dao","two");
							break;
					}
					//添加子条件
					
					//添加辖区局条件
					ajaxUrl += selectRegion == "all" ? "" : "&district=" + selectRegion;
				}
					break;
			}
        	$.ajax({
        		url:ajaxUrl,
        		dataType:"json",
        		type:"GET",
        		beforeSend:function(){
        			$(selector+" #informationCentre").css("height","auto");
        			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
        			$(selector+" .informationCentre .packet").html(loading);
        		},
        		complete:function(data){
        			if(data.readyState==4)
        				{
        				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
        				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
        				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
	        				var jsonData=JSON.parse(data.responseText);
	        				//请求数据
	        				var jsonProject=jsonData.results;
	        				$(selector+" .informationCentre .packet").html("");
	        				for(var i=0;i<jsonProject.length;i++){
	        					var j=i+1;
								$(selector+" .informationCentre .packet").append(getHtmlByType(dataSelectType,selectTypeClass,jsonProject[i],j,i));
	        				}
							//总共要素个数
	        				ghCount=jsonData.totalCounts;
	        				//判断，如果内容只有一页就隐藏分页栏
	        				if(ghCount<=10){
	        						$(selector+" .informationCentre .paging").hide();
	        					}else{
	        						$(selector+" .informationCentre .paging").show();
	        					}
	        				if(ghCount==0){
	        					$(selector+" .informationCentre .packet").html("没有该信息！");
	        					$(selector+" .informationCentre .packet").css({"text-align":"center","color":"#EB873B","line-height":"100px"});
	        				}else{
	        					$(selector+" .informationCentre .packet").css({"text-align":"left","color":"auto","line-height":"auto"});
	        				}
		    				//分页
		    				$(function(){
		    						$(selector+" #paging").cypager({pg_size:10,pg_nav_count:5,pg_total_count:ghCount,pg_call_fun:function(count){

										switch (dataSelectType) {
											case"project":{
												switch (selectTypeClass){
													case "规划项目":
														ajaxUrl=selectIndexData.dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "";
														break;
													case "大中修项目":
														ajaxUrl=selectIndexData.dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "";
														break;
													default:
														ajaxUrl=selectIndexData.dataUrl[selectTypeClass]+"page.pageSize=10&page.pageNo=" + count + "";
														break;
												}
												switch (selectTypeClass){
													case "规划项目":
														ajaxUrl+=selectRegion=="all"?"":"&fileter_EQS_district=" + selectRegion ;
														break;
													case"前期项目":
													case "大中修项目":
														ajaxUrl+=selectRegion=="all"?"":"&filter_EQS_district=" + selectRegion ;
														break;
													case "施工项目":
														ajaxUrl+=selectRegion=="all"?"":"&filter_EQS_district=" + selectRegion ;
														break;
												};
											}
												break;
											case "road":
											{
												switch (selectTypeClass) {
													case "公路":
														ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "&page.pageSize=10&page.pageNo=" + count + "";
														break;
													case "市政道路":
														ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "&page.pageSize=10&page.pageNo=" + count + "";
														break;
												}
												//添加子条件
												ajaxUrl += selectTypeClassChild== "全部" ? "" : "&filter_EQS_techGrade=" + selectIndexData.childData[selectTypeClass].queryCondition[selectTypeClassChild];
												//添加辖区局条件
												ajaxUrl += selectRegion == "all" ? "" : "&filter_EQS_district=" + selectRegion;
											}
												break;
											case "bridge":
											{
												switch (selectTypeClass) {
												case "桥梁":
													ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "?page.pageSize=10&page.pageNo=" + count + "";
													ajaxUrl += selectTypeClassChild == "全部" ? "" : "&filter_EQS_bridgeKind=" + selectIndexData.childData[selectTypeClass].queryCondition[selectTypeClassChild];
													break;
												case "隧道":
													ajaxUrl = selectIndexData.dataUrl[selectTypeClass] + "?page.pageSize=10&page.pageNo=" + count + "";
													ajaxUrl += selectTypeClassChild == "全部" ? "" : "&filter_EQS_tunnelkind=" + selectIndexData.childData[selectTypeClass].queryCondition[selectTypeClassChild];
													break;
												}
												//添加子条件
												
												//添加辖区局条件
												ajaxUrl += selectRegion == "all" ? "" : "&filter_EQS_district=" + selectRegion;
											}
												break;
										}
		    							$.ajax({
		    		                		url:ajaxUrl,
		    		                		dataType:"json",
		    		                		type:"GET",
		    		                		beforeSend:function(){
		    		                			$(selector+" #informationCentre").css("height","auto");
		    		                			$(selector+" .informationCentre .paging").css({"height":"0px","border-top":"1px solid #fff"});
		    		                			$(selector+" .informationCentre .packet").html(loading);
		    		                		},
		    		                		complete:function(data){
		    		                			if(data.readyState==4){
		    		                				$(selector+" .informationCentre .paging").css({"height":"auto","border-top":"1px solid #F6F6F6"});
		    		        	        				var jsonData=JSON.parse(data.responseText);
		    		        	        				//请求数据
		    		        	        				var jsonProject=jsonData.results;
		    		        	        				$(selector+" .informationCentre .packet").html("");
		    		        	        				for(var i=0;i<jsonProject.length;i++){
		    		        	        					var j=i+1;
															$(selector+" .informationCentre .packet").append(getHtmlByType(dataSelectType,selectTypeClass,jsonProject[i],j,i));
		    		        	        				}
		    		        	        				//高度auto
		    		        	        				$(function(){
		    		        	        					var h = $(".search").height();
		    		        	        					var w2 = 0.8;
		    		        	        					var w;
		    		        	        					autodivheight();
		    		        	        					if(w>w2){autoHeight()}
		    		        	        					function autodivheight(){
		    		        	        					    var winHeight=0;
		    		        	        					    if (window.innerHeight)
		    		        	        					        winHeight = window.innerHeight;
		    		        	        					    else if ((document.body) && (document.body.clientHeight))
		    		        	        					        winHeight = document.body.clientHeight;
		    		        	        					    if (document.documentElement && document.documentElement.clientHeight)
		    		        	        					        winHeight = document.documentElement.clientHeight;
		    		        	        					    w = h/winHeight;
		    		        	        					    return w;
		    		        	        					}
		    		        	        				});
		    		                				}
		    		                		},
		    		                	});
		    						}});
	        					});
		    				//高度auto
	        				$(function(){
	        					var h = $(".search").height();
	        					var w2 = 0.8;
	        					var w;
	        					autodivheight();
	        					if(w>w2){autoHeight()}
	        					function autodivheight(){
	        					    var winHeight=0;
	        					    if (window.innerHeight)
	        					        winHeight = window.innerHeight;
	        					    else if ((document.body) && (document.body.clientHeight))
	        					        winHeight = document.body.clientHeight;
	        					    if (document.documentElement && document.documentElement.clientHeight)
	        					        winHeight = document.documentElement.clientHeight;
	        					    w = h/winHeight;
	        					    return w;
	        					}
	        				});
        				}
        		},
        	});
        },
        /* end add_js */
        mapLinkage:function(e){
        	//选中样式
        	var num = e.currentTarget.dataset.num;
        	$(".informationCentre div.info").eq(num).addClass("on").siblings().removeClass("on");
        	$(".informationCentre div.info").eq(num).find(".identification").addClass("on").parent().siblings().find(".identification").removeClass("on");
			//点击之前就清空
			m_reMoveLayerAndolay();

            var selectNode= e.target;
			if(!selectNode.hasAttribute("data-type")){
					while(!selectNode.hasAttribute("data-type")){
						selectNode=selectNode.parentElement;
					}
			};

			var selectType=selectNode.getAttribute("data-type");
			var queryId=selectNode.getAttribute("data-id");
			var selectIndexData=indexData[selectType];
			if(!selectIndexData) return;
			switch (selectIndexData.dataType[selectTypeClass])
			{
				case "WFS":
					this.loading();
					var queryData=selectIndexData.querUrl[selectTypeClass];
					var f = ol.format.ogc.filter;
					var featureRequest = new ol.format.WFS().writeGetFeature({
						srsName: 'EPSG:4326',
						featureNS: queryData.featureNS,
						featurePrefix: queryData.featurePrefix,
						featureTypes: queryData.layers,
						outputFormat: 'application/json',
						filter: f.equalTo(queryData.queryFieldName, queryId)
					});
					fetch(queryData.url, {
						method: 'POST',
						body: new XMLSerializer().serializeToString(featureRequest)
					}).then(function(response) {
						return response.json();
					}).then(this.proxy(function(json) {
						var features = new ol.format.GeoJSON().readFeatures(json,{dataProjection: "EPSG:4326", featureProjection: "EPSG:3857"});
						if (features.length > 0) {
							var detailSource = new ol.source.Vector();
							var detailLayer = new ol.layer.Vector({
								source: detailSource,
								style: HightLightstyleFunction
							});
							detailSource.addFeatures(features);
							//结果定位
							if(features.length>0){
								map.getView().fit(features[0].getGeometry(),map.getSize(),{padding: [170, 50, 30, 150]});
							}
							//显示信息框
							ShowInfoWindow(features[0],selectNode.getAttribute("data-name"),selectIndexData,queryId);
							m_TempLayer = detailLayer;
							map.addLayer(detailLayer);
							Message_bone.trigger("suggestHide");
						} else {
							var result = [];
							for (var i = 0; i < Math.min(7, features.length); i += 1) {
								result.push(features[i].getProperties());
							}
							result.length && Message_bone.trigger("suggestShow", [result]);

						}
						this.loadend();
					}));
					break;
			}
        },
    });
    
	//获取列表子项HTML
	function getHtmlByType(selectType,selectTypeClass,data,sortIndex,num){
			var returnHtml="";
			switch (selectType)
			{
				case "project":
					returnHtml =
						'<div class="info" data-num="'+num+'" data-type="'+selectType+'" data-id="'+data.id+'" data-name="'+data.projectName+'">'
						+'<div class="identification" >'+sortIndex+'</div>'
						+'<div class="infoContent">'
						+'<div class="list"><span>项目编号：</span><p class="number">'+data.projectCode+'</p></div><div style="clear:both;"></div>'
						+'<div class="list"><span>项目名称：</span><p class="project">'+data.projectName+'</p></div><div style="clear:both;"></div>'
						+'<div class="list"><span class="placeTitle">项目所在位置：</span><p class="place">'+data.projectLocation+'</p></div><div style="clear:both;"></div>'
						+'</div><div style="clear:both;"></div>'
						+'</div>'	;
					break;
				case "road":
					returnHtml =
						'<div class="info" data-num="'+num+'" data-type="'+selectType+'" data-id="'+data.roadCode+'" data-name="'+data.roadName+'">'
						+'<div class="identification" >'+sortIndex+'</div>'
						+'<div class="infoContent">'
						+'<div class="list"><span>道路编号：</span><p class="number">'+data.roadCode+'</p></div><div style="clear:both;"></div>'
						+'<div class="list"><span>道路名称：</span><p class="project">'+data.roadName+'</p></div><div style="clear:both;"></div>'
						+'<div class="list"><span class="placeTitle">道路所在位置：</span><p class="place">'+Pengtu.buildCodeName(2050,data.district)+' '+data.subdistrict+'</p></div><div style="clear:both;"></div>'
						+'</div><div style="clear:both;"></div>'						
						+'</div>'	;
					break;
				case "bridge":
					switch (selectTypeClass)
					{
						case "桥梁":
							returnHtml =
								'<div class="info" data-num="'+num+'" data-type="'+selectType+'" data-id="'+data.bridgeCode+'" data-name="'+data.bridgeName+'">'
								+'<div class="identification" >'+sortIndex+'</div>'
								+'<div class="infoContent">'
								+'<div class="list"><span>桥梁编号：</span><p class="number">'+data.bridgeCode+'</p></div><div style="clear:both;"></div>'
								+'<div class="list"><span>桥梁名称：</span><p class="project">'+data.bridgeName+'</p></div><div style="clear:both;"></div>'
								+'<div class="list"><span class="placeTitle">桥梁所在位置：</span><p class="place">'+data.partName+'</p></div><div style="clear:both;"></div>'
								+'</div><div style="clear:both;"></div>'
								+'</div>'	;
							break;
						case "隧道":
							returnHtml =
								'<div class="info" data-num="'+num+'" data-type="'+selectType+'" data-id="'+data.tunnelcode+'" data-name="'+data.tunnelname+'">'
								+'<div class="identification" >'+sortIndex+'</div>'
								+'<div class="infoContent">'
								+'<div class="list"><span>隧道编号：</span><p class="number">'+data.tunnelcode+'</p></div><div style="clear:both;"></div>'
								+'<div class="list"><span>隧道名称：</span><p class="project">'+data.tunnelname+'</p></div><div style="clear:both;"></div>'
								+'<div class="list"><span class="placeTitle">隧道所在位置：</span><p class="place">'+data.partname+'</p></div><div style="clear:both;"></div>'
								+'</div><div style="clear:both;"></div>'
								+'</div>'	;
							break;
					}
					break;
			}
		  return returnHtml;
	};
	//实时获取输入框内容
//    $(".js-search").bind("input oninput", function() {  
//    var project = $(".container li").eq(0).hasClass("hover");
//    var bridge = $(".container li").eq(2).hasClass("hover");
//    if(!project&&!bridge){
//       $(".container li").eq(1).addClass("hover").find("i").addClass("hover");
//       $(".roadContent").show().find(".projectBranch li").eq(1).find("span").html("全部");
//    }
//   });
	//高亮符号
	var image = new ol.style.Icon({
		src: "/ssjc/images/gis/marker.png",
		scale: 0.8
	});
	var hightLightStyles = {
		'Point': new ol.style.Style({
			image: image
		}),
		'LineString': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#00FFFF',
				width: 4
			})
		}),
		'MultiLineString': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#00FFFF',
				width: 4
			})
		}),
		'Polygon': new ol.style.Style({
			stroke: new ol.style.Stroke({
				color: '#00FFFF',
				lineDash: [4],
				width: 4
			}),
			fill: new ol.style.Fill({
				color: 'rgba(0, 0, 255, 0.1)'
			})
		})
	};
	var HightLightstyleFunction = function(feature) {
		return hightLightStyles[feature.getGeometry().getType()];
	};
	//弹窗显示信息框
   function ShowInfoWindow(featrueData,tile,proData,id){
	   if (featrueData) {
		   var overlay = new ol.Overlay({
			   element: document.getElementById("overlay"),
			   positioning: "bottom-center"
		   });
		   map.addOverlay(overlay);
		   var element = overlay.getElement();
		   $(element).addClass("detail");
		   $(element).find(".ohead p").html(tile);
		   $(element).find(".ocontent").empty();
		   var property = featrueData.getProperties();
		   for (var key in property) {
			   if (typeof property[key] === "string" && key !== "projectId") {
				   if(Pengtu.buildCodeName("7777", key)!=key)
				   $("<p>").text(Pengtu.buildCodeName("7777", key) + ": " +Pengtu.buildCodeName("2010",  property[key])).appendTo($(element).find(".ocontent"));
			   }
		   }
		   if(selectTypeClass.indexOf("路")>0) {
			   $("<p>").text("道路生命周期:").append($("<a>").text("查看详情").attr({
				   "href":  proData.detailUrl[selectTypeClass]+"roadname="+featrueData.getProperties()["name"]+"&district="+featrueData.getProperties()["quname"]+"&roadCode="+featrueData.getProperties()["hb_code"],
				   "target": "_blank"
			   })).appendTo($(element).find(".ocontent"));
			   $(element).data("query", overlay);
		   }
		   else if(selectTypeClass.indexOf("项目")>0){
			   $("<p>").text("详细信息:").append($("<a>").text("查看详情").attr({
				   "href": proData.detailUrl[selectTypeClass] + id,
				   "target": "_blank"
			   })).appendTo($(element).find(".ocontent"));
			   $(element).data("query", overlay);
		   }
		   else if(selectTypeClass.indexOf("桥梁")>0){
			   $("<p>").text("桥梁卡片:").append($("<a>").text("查看详情").attr({
				   "href": proData.detailUrl[selectTypeClass] + id,
				   "target": "_blank"
			   })).appendTo($(element).find(".ocontent"));
			   $(element).data("query", overlay);
		   }
		   overlay.setPosition(GetPointByGeometry(featrueData.getGeometry()));
	   } else {
		   var olay = $("#overlay").data("query");
		   olay && olay.setPosition([9999, 9999]);
	   }
   };
	//获取点位置
	function  GetPointByGeometry(geometry){
		var coordinate=ol.extent.getCenter(geometry.getExtent());
		return coordinate;
	};
    var trigger = new Trigger("#searchContain");
    trigger.trigger("searchBox", "keyup");
    return {
        searchBoxController: trigger
    }
    
});
